# $Id: PKGBUILD 85735 2013-03-06 02:20:18Z bgyorgy $
# Maintainer: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: dtw <dibble.at.thewrecker.dot.net>
# Contributor: shawnifoley http://bbs.archlinux.org/viewtopic.php?t=11492
# Contributor: sebastien le guillerm <geekitus@tele2.fr>

pkgname=wifi-radar
pkgver=2.0.s08
pkgrel=5
pkgdesc="A PyGTK2 utility for managing WiFi profiles"
arch=('any')
url="http://wifi-radar.berlios.de/"
license=('GPL')
depends=('net-tools' 'pygtk' 'wireless_tools')
optdepends=('polkit-gnome: needed if you launch wifi-radar from menu')
backup=('etc/wifi-radar.conf')
install=$pkgname.install
source=(http://download.berlios.de/$pkgname/$pkgname-$pkgver.tar.bz2
        org.archlinux.pkexec.wifi-radar.policy)
md5sums=('cbad24805d5dc6696e38dc1df619c819'
         'b66236233a5644a75e638ab6fdcc54fc')

build() {
  cd ${srcdir}/$pkgname-$pkgver

  # python2 fix
  sed -i 's_^#!.*/usr/bin/python_#!/usr/bin/python2_' wifi-radar

# Fix iwlist and iwconfig path
  sed -i 's|/sbin/iwlist|/usr/sbin/iwlist|' $pkgname
  sed -i 's|/sbin/iwconfig|/usr/sbin/iwconfig|' $pkgname

  make 
}
package() {
  cd ${srcdir}/$pkgname-$pkgver
  make DESTDIR=${pkgdir}/usr sysconfdir=${pkgdir}/etc install

  # Install policy file
  install -Dm644 "${srcdir}/org.archlinux.pkexec.wifi-radar.policy" "${pkgdir}/usr/share/polkit-1/actions/org.archlinux.pkexec.wifi-radar.policy"

  # Modify desktop file
  sed -i -e "s/^Exec=.*/Exec=pkexec --disable-internal-agent wifi-radar/" "${pkgdir}/usr/share/applications/wifi-radar.desktop"
}
